home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / Src Code / IEDIGENE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-24  |  5.0 KB  |  186 lines

  1. {**********************************************}
  2. {  TCustomChart (or derived) Editor Dialog     }
  3. {  Copyright (c) 1996-98 by David Berneda      }
  4. {**********************************************}
  5. {$I teedefs.inc}
  6. unit IEdiGene;
  7.  
  8. interface
  9.  
  10. uses
  11.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  12.   StdCtrls, ExtCtrls, Chart, ComCtrls;
  13.  
  14. type
  15.   TFormTeeGeneral = class(TForm)
  16.     GBZoom: TGroupBox;
  17.     LSteps: TLabel;
  18.     CBAllowZoom: TCheckBox;
  19.     CBAnimatedZoom: TCheckBox;
  20.     SEAniZoomSteps: TEdit;
  21.     RGPanning: TRadioGroup;
  22.     CBClipPoints: TCheckBox;
  23.     BPrint: TButton;
  24.     BExport: TButton;
  25.     GBMargins: TGroupBox;
  26.     SETopMa: TEdit;
  27.     SELeftMa: TEdit;
  28.     SEBotMa: TEdit;
  29.     SERightMa: TEdit;
  30.     UDTopMa: TUpDown;
  31.     UDRightMa: TUpDown;
  32.     UDLeftMa: TUpDown;
  33.     UDBotMa: TUpDown;
  34.     UDAniZoomSteps: TUpDown;
  35.     procedure BPrintClick(Sender: TObject);
  36.     procedure CBAllowZoomClick(Sender: TObject);
  37.     procedure CBClipPointsClick(Sender: TObject);
  38.     procedure CBAnimatedZoomClick(Sender: TObject);
  39.     procedure FormShow(Sender: TObject);
  40.     procedure BExportClick(Sender: TObject);
  41.     procedure RGPanningClick(Sender: TObject);
  42.     procedure SEAniZoomStepsChange(Sender: TObject);
  43.     procedure SERightMaChange(Sender: TObject);
  44.     procedure SETopMaChange(Sender: TObject);
  45.     procedure SEBotMaChange(Sender: TObject);
  46.     procedure SELeftMaChange(Sender: TObject);
  47.     procedure FormCreate(Sender: TObject);
  48.   private
  49.     { Private declarations }
  50.     CreatingForm:Boolean;
  51.     Function ChangeMargin(UpDown:TUpDown; APos,OtherSide:Integer):Integer;
  52.   public
  53.     { Public declarations }
  54.     TheChart:TCustomChart;
  55.     Constructor CreateChart(Owner:TComponent; AChart:TCustomChart);
  56.   end;
  57.  
  58. { Show the Export dialog }
  59. Procedure ChartExport(AOwner:TForm; AChart:TCustomChart);
  60.  
  61. implementation
  62.  
  63. {$R *.DFM}
  64. Uses TeeProcs, TeePrevi, TeExport, TeeStore;
  65.  
  66. Procedure TeeExportSaveChart(ExportPanel:TCustomTeePanel; Const AFileName:String);
  67. begin
  68.   if ExportPanel is TCustomChart then
  69.      SaveChartToFile(TCustomChart(ExportPanel),AFileName)
  70.   else
  71.      SaveTeeToFile(ExportPanel,AFileName);
  72. end;
  73.  
  74. Procedure ChartExport(AOwner:TForm; AChart:TCustomChart);
  75. begin
  76.   With TTeeExportForm.Create(AOwner) do
  77.   try
  78.     ExportPanel:=AChart;
  79.     TeeExportSave:=TeeExportSaveChart;
  80.     try
  81.       ShowModal;
  82.     finally
  83.       TeeExportSave:=nil;
  84.     end;
  85.   finally
  86.     Free;
  87.   end;
  88. end;
  89.  
  90. { Chart General }
  91. Constructor TFormTeeGeneral.CreateChart(Owner:TComponent; AChart:TCustomChart);
  92. begin
  93.   inherited Create(Owner);
  94.   TheChart:=AChart;
  95. end;
  96.  
  97. procedure TFormTeeGeneral.BPrintClick(Sender: TObject);
  98. begin
  99.   ChartPreview(Self,TheChart);
  100. end;
  101.  
  102. procedure TFormTeeGeneral.CBAllowZoomClick(Sender: TObject);
  103. begin
  104.   TheChart.AllowZoom:=CBAllowZoom.Checked;
  105. end;
  106.  
  107. procedure TFormTeeGeneral.CBClipPointsClick(Sender: TObject);
  108. begin
  109.   TheChart.ClipPoints:=CBClipPoints.Checked;
  110. end;
  111.  
  112. procedure TFormTeeGeneral.CBAnimatedZoomClick(Sender: TObject);
  113. begin
  114.   TheChart.AnimatedZoom:=CBAnimatedZoom.Checked;
  115. end;
  116.  
  117. procedure TFormTeeGeneral.FormShow(Sender: TObject);
  118. begin
  119.   With TheChart do
  120.   begin
  121.     RGPanning.ItemIndex    :=Ord(AllowPanning);
  122.     CBClipPoints.Checked   :=ClipPoints;
  123.  
  124.     UDTopMa.Position       :=MarginTop;
  125.     UDLeftMa.Position      :=MarginLeft;
  126.     UDBotMa.Position       :=MarginBottom;
  127.     UDRightMa.Position     :=MarginRight;
  128.  
  129.     CBAllowZoom.Checked    :=AllowZoom;
  130.     CBAnimatedZoom.Checked :=AnimatedZoom;
  131.     UDAniZoomSteps.Position:=AnimatedZoomSteps;
  132.   end;
  133.   CreatingForm:=False;
  134. end;
  135.  
  136. procedure TFormTeeGeneral.BExportClick(Sender: TObject);
  137. begin
  138.   ChartExport(Self,TheChart);
  139. end;
  140.  
  141. procedure TFormTeeGeneral.RGPanningClick(Sender: TObject);
  142. begin
  143.   TheChart.AllowPanning:=TPanningMode(RGPanning.ItemIndex);
  144. end;
  145.  
  146. procedure TFormTeeGeneral.SEAniZoomStepsChange(Sender: TObject);
  147. begin
  148.   if not CreatingForm then TheChart.AnimatedZoomSteps:=UDAniZoomSteps.Position;
  149. end;
  150.  
  151. Function TFormTeeGeneral.ChangeMargin(UpDown:TUpDown; APos,OtherSide:Integer):Integer;
  152. begin
  153.   result:=APos;
  154.   if not CreatingForm then
  155.   With UpDown do
  156.   if Position+OtherSide<100 then result:=Position
  157.                             else Position:=APos;
  158. end;
  159.  
  160. procedure TFormTeeGeneral.SERightMaChange(Sender: TObject);
  161. begin
  162.   With TheChart do MarginRight:=ChangeMargin(UDRightMa,MarginRight,MarginLeft);
  163. end;
  164.  
  165. procedure TFormTeeGeneral.SETopMaChange(Sender: TObject);
  166. begin
  167.   With TheChart do MarginTop:=ChangeMargin(UDTopMa,MarginTop,MarginBottom);
  168. end;
  169.  
  170. procedure TFormTeeGeneral.SEBotMaChange(Sender: TObject);
  171. begin
  172.   With TheChart do MarginBottom:=ChangeMargin(UDBotMa,MarginBottom,MarginTop);
  173. end;
  174.  
  175. procedure TFormTeeGeneral.SELeftMaChange(Sender: TObject);
  176. begin
  177.   With TheChart do MarginLeft:=ChangeMargin(UDLeftMa,MarginLeft,MarginRight);
  178. end;
  179.  
  180. procedure TFormTeeGeneral.FormCreate(Sender: TObject);
  181. begin
  182.   CreatingForm:=True;
  183. end;
  184.  
  185. end.
  186.